package com.sky.mapper;

import com.sky.entity.AiChatRecord;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * AI聊天记录Mapper接口
 */
@Mapper
public interface AiChatRecordMapper {

    /**
     * 插入聊天记录
     * @param record 聊天记录
     */
    @Insert("INSERT INTO ai_chat_record(user_id, question, answer, create_time) " +
            "VALUES(#{userId}, #{question}, #{answer}, #{createTime})")
    void insert(AiChatRecord record);
    
    /**
     * 根据用户ID查询聊天记录
     * @param userId 用户ID
     * @return 聊天记录列表
     */
    @Select("SELECT * FROM ai_chat_record WHERE user_id = #{userId} ORDER BY create_time DESC LIMIT 20")
    List<AiChatRecord> listByUserId(@Param("userId") Long userId);
} 